// stores/counter.js
import request from "../utils/request"
import { defineStore } from 'pinia'
import { treeDataTranslate } from "../utils/treeDataTranslate"
export const menu = defineStore('menu', {
    state: () => {
        return {
            menu_list: []
        }
    },
    // 也可以定义为
    // state: () => ({ count: 0 })
    actions: {
        menu_get_list() {
            request({
                url: `/sys/menu/table?t=${new Date().getTime()}`,
                method: "get",
            }).then((res) => {
                this.menu_list = treeDataTranslate(res.data, "menuId", "parentId")
                console.log(this.menu_list, "this.menu_list");

            });
        }
    },
    persist: {
        enabled: true, // 开启持久化存储
        strategies: [
            {
                // 修改存储中使用的键名称，默认为当前 Store的id
                key: 'custom',
                // 修改为 sessionStorage，默认为 localStorage
                storage: sessionStorage,
                // []意味着没有状态被持久化(默认为undefined，持久化整个状态)
                paths: [],
            }
        ]
    }
})